@chevre/domain 21.18.0-alpha.4 → 21.18.0-alpha.41

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 (142) hide show
  1. package/example/src/chevre/aggreateOwnershipInfosByOrder.ts +24 -0
  2. package/example/src/chevre/offerCatalog2offerCatalogItem.ts +4 -0
  3. package/example/src/chevre/searchAcceptedOfferIds.ts +57 -0
  4. package/example/src/chevre/searchOffers.ts +41 -37
  5. package/example/src/chevre/searchOrderAcceptedOffers.ts +12 -12
  6. package/example/src/chevre/searchOrders.ts +36 -19
  7. package/example/src/chevre/searchReservationsByOrder.ts +30 -0
  8. package/example/src/chevre/searchTransactions.ts +41 -0
  9. package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
  10. package/example/src/chevre/upsertMoviesByIdentifier.ts +5 -4
  11. package/example/src/chevre/upsertOfferCatalogsByIdentifier.ts +46 -0
  12. package/example/src/chevre/upsertOffersByIdentifier.ts +94 -0
  13. package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +104 -0
  14. package/lib/chevre/credentials.d.ts +0 -3
  15. package/lib/chevre/credentials.js +4 -3
  16. package/lib/chevre/repo/acceptedOffer.d.ts +60 -0
  17. package/lib/chevre/repo/acceptedOffer.js +158 -0
  18. package/lib/chevre/repo/creativeWork.d.ts +12 -2
  19. package/lib/chevre/repo/creativeWork.js +39 -25
  20. package/lib/chevre/repo/event.d.ts +15 -0
  21. package/lib/chevre/repo/event.js +66 -0
  22. package/lib/chevre/repo/offer.d.ts +14 -5
  23. package/lib/chevre/repo/offer.js +94 -19
  24. package/lib/chevre/repo/offerCatalog.d.ts +18 -1
  25. package/lib/chevre/repo/offerCatalog.js +51 -39
  26. package/lib/chevre/repo/order.d.ts +14 -54
  27. package/lib/chevre/repo/order.js +46 -180
  28. package/lib/chevre/repo/paymentService.d.ts +30 -0
  29. package/lib/chevre/repo/paymentService.js +75 -0
  30. package/lib/chevre/repo/place.js +14 -10
  31. package/lib/chevre/repo/product.d.ts +41 -10
  32. package/lib/chevre/repo/product.js +94 -47
  33. package/lib/chevre/repo/transaction.d.ts +5 -4
  34. package/lib/chevre/repository.d.ts +10 -7
  35. package/lib/chevre/repository.js +28 -17
  36. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +10 -1
  37. package/lib/chevre/service/aggregation/event/findEventOffers.js +10 -1
  38. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  39. package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +3 -1
  40. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  41. package/lib/chevre/service/assetTransaction/pay.d.ts +2 -0
  42. package/lib/chevre/service/assetTransaction/pay.js +47 -34
  43. package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
  44. package/lib/chevre/service/assetTransaction/refund/factory.js +0 -5
  45. package/lib/chevre/service/assetTransaction/refund.js +15 -3
  46. package/lib/chevre/service/assetTransaction/registerService.js +18 -2
  47. package/lib/chevre/service/assetTransaction/reserve/factory/price.js +1 -1
  48. package/lib/chevre/service/assetTransaction/reserve.js +32 -2
  49. package/lib/chevre/service/delivery/factory.d.ts +3 -1
  50. package/lib/chevre/service/delivery/factory.js +4 -2
  51. package/lib/chevre/service/delivery.d.ts +1 -2
  52. package/lib/chevre/service/delivery.js +1 -3
  53. package/lib/chevre/service/event.js +1 -1
  54. package/lib/chevre/service/moneyTransfer.js +11 -1
  55. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  56. package/lib/chevre/service/offer/event/factory.js +4 -2
  57. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +40 -5
  58. package/lib/chevre/service/offer/product/factory.js +1 -1
  59. package/lib/chevre/service/offer/product/searchProductOffers.js +10 -1
  60. package/lib/chevre/service/offer/product.d.ts +0 -14
  61. package/lib/chevre/service/offer/product.js +61 -44
  62. package/lib/chevre/service/order/confirmPayTransaction.d.ts +2 -0
  63. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  64. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +3 -1
  65. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +4 -1
  66. package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
  67. package/lib/chevre/service/order/deleteOrder.js +15 -4
  68. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +3 -1
  69. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
  70. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +3 -3
  71. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +15 -9
  72. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +11 -0
  73. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.js +54 -0
  74. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +10 -0
  75. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +38 -0
  76. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +12 -0
  77. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +111 -0
  78. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +12 -0
  79. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +64 -0
  80. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +10 -0
  81. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +103 -0
  82. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +23 -0
  83. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +180 -0
  84. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +14 -0
  85. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +214 -0
  86. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +10 -0
  87. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +110 -0
  88. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +14 -0
  89. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +164 -0
  90. package/lib/chevre/service/order/onOrderStatusChanged.d.ts +9 -15
  91. package/lib/chevre/service/order/onOrderStatusChanged.js +11 -446
  92. package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +6 -0
  93. package/lib/chevre/service/order/onOrderUpdated/factory.js +45 -0
  94. package/lib/chevre/service/order/onOrderUpdated.js +1 -1
  95. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  96. package/lib/chevre/service/order/placeOrder.d.ts +2 -3
  97. package/lib/chevre/service/order/placeOrder.js +65 -22
  98. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  99. package/lib/chevre/service/order/returnOrder.js +34 -13
  100. package/lib/chevre/service/order/sendOrder.d.ts +2 -2
  101. package/lib/chevre/service/order/sendOrder.js +19 -6
  102. package/lib/chevre/service/order.d.ts +2 -2
  103. package/lib/chevre/service/order.js +2 -2
  104. package/lib/chevre/service/payment/any.js +1 -1
  105. package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -2
  106. package/lib/chevre/service/payment/paymentCard.js +9 -2
  107. package/lib/chevre/service/reserve/searchByOrder.d.ts +21 -0
  108. package/lib/chevre/service/reserve/searchByOrder.js +113 -0
  109. package/lib/chevre/service/reserve/verifyToken4reservation.js +0 -11
  110. package/lib/chevre/service/reserve.d.ts +2 -1
  111. package/lib/chevre/service/reserve.js +3 -1
  112. package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
  113. package/lib/chevre/service/task/deleteTransaction.js +2 -0
  114. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +5 -6
  115. package/lib/chevre/service/task/onAuthorizationCreated.js +9 -18
  116. package/lib/chevre/service/task/onOrderPaymentCompleted.js +5 -6
  117. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +1 -1
  118. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  119. package/lib/chevre/service/task/placeOrder.js +10 -17
  120. package/lib/chevre/service/task/returnOrder.js +10 -17
  121. package/lib/chevre/service/task/sendOrder.js +10 -17
  122. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -7
  123. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  124. package/lib/chevre/service/transaction/moneyTransfer.js +3 -4
  125. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +0 -4
  126. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +0 -86
  127. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
  128. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
  129. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +1 -0
  130. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +3 -3
  131. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -0
  132. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -1
  133. package/lib/chevre/service/transaction/returnOrder.d.ts +3 -0
  134. package/lib/chevre/service/transaction/returnOrder.js +73 -55
  135. package/package.json +3 -3
  136. package/example/src/chevre/transaction/findPaymentCardPermit.ts +0 -29
  137. package/lib/chevre/repo/action/registerServiceInProgress.d.ts +0 -29
  138. package/lib/chevre/repo/action/registerServiceInProgress.js +0 -58
  139. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +0 -42
  140. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +0 -467
  141. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +0 -26
  142. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +0 -65
@@ -1,467 +0,0 @@
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
- var _a;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.createOnOrderCancelledTasksByTransaction = exports.createOnOrderReturnedTasksByTransaction = exports.createOnOrderSentTasksByTransaction = exports.createConfirmRegisterServiceActionObjectByOrder = exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createInformTasks = exports.getOrderWithToken = void 0;
14
- const google_libphonenumber_1 = require("google-libphonenumber");
15
- const jwt = require("jsonwebtoken");
16
- const util_1 = require("util");
17
- const credentials_1 = require("../../../credentials");
18
- const factory = require("../../../factory");
19
- const order_1 = require("../../../factory/order");
20
- const reservedAgentIdentifireNames_1 = require("../../../factory/reservedAgentIdentifireNames");
21
- const settings_1 = require("../../../settings");
22
- const informOrder = (_a = settings_1.settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
23
- function getOrderWithToken(params) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- if (typeof credentials_1.credentials.hub.clientId !== 'string') {
26
- return params.order;
27
- }
28
- // 最適化(2023-01-31~)
29
- const order4token = {
30
- typeOf: params.order.typeOf,
31
- orderNumber: params.order.orderNumber
32
- };
33
- const token = yield new Promise((resolve, reject) => {
34
- // 所有権を暗号化する
35
- jwt.sign(order4token, credentials_1.credentials.jwt.secret, {
36
- audience: [credentials_1.credentials.hub.clientId],
37
- issuer: credentials_1.credentials.jwt.issuer,
38
- expiresIn: params.expiresIn
39
- }, (err, encoded) => {
40
- if (err instanceof Error) {
41
- reject(err);
42
- }
43
- else {
44
- if (typeof encoded !== 'string') {
45
- reject(new factory.errors.ServiceUnavailable('order cannot be signed unexpectedly'));
46
- }
47
- else {
48
- resolve(encoded);
49
- }
50
- }
51
- });
52
- });
53
- return Object.assign(Object.assign({}, params.order), {
54
- // 注文トークンを情報付加
55
- token });
56
- });
57
- }
58
- exports.getOrderWithToken = getOrderWithToken;
59
- const ASTERISK_CHARACTER = '*';
60
- function createInformTasks(order) {
61
- var _a;
62
- const taskRunsAt = new Date();
63
- let informTasks = [];
64
- if (Array.isArray(informOrder) && informOrder.length > 0) {
65
- const order4inform = creteOrder4inform(order);
66
- let recipientId = '';
67
- if (typeof order.orderStatus === 'string') {
68
- recipientId = order.customer.id;
69
- if (order.orderStatus === factory.orderStatus.OrderReturned) {
70
- if (typeof ((_a = order.returner) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
71
- recipientId = order.returner.id;
72
- }
73
- }
74
- }
75
- informTasks = informOrder.map((informOrderParams) => {
76
- var _a, _b;
77
- const informActionAttributes = {
78
- agent: order.project,
79
- object: order4inform,
80
- project: order.project,
81
- recipient: {
82
- url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
83
- id: recipientId,
84
- name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
85
- typeOf: factory.creativeWorkType.WebApplication
86
- },
87
- typeOf: factory.actionType.InformAction
88
- };
89
- return {
90
- project: order.project,
91
- name: factory.taskName.TriggerWebhook,
92
- status: factory.taskStatus.Ready,
93
- runsAt: taskRunsAt,
94
- remainingNumberOfTries: 10,
95
- numberOfTried: 0,
96
- executionResults: [],
97
- data: informActionAttributes
98
- };
99
- });
100
- }
101
- return informTasks;
102
- }
103
- exports.createInformTasks = createInformTasks;
104
- function creteOrder4inform(order) {
105
- if (typeof order.orderStatus === 'string') {
106
- if (order.orderStatus === factory.orderStatus.OrderReturned) {
107
- // 返品注文通知内容を最適化(2022-12-28~)
108
- return Object.assign(Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, orderStatus: order.orderStatus }, (order.dateReturned !== undefined) ? { dateReturned: order.dateReturned } : undefined), (typeof order.id === 'string') ? { id: order.id } : undefined);
109
- }
110
- else if (order.orderStatus === factory.orderStatus.OrderDelivered) {
111
- // 配送済注文通知内容を最適化(2022-12-29~)
112
- return Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, orderStatus: order.orderStatus }, (typeof order.id === 'string') ? { id: order.id } : undefined);
113
- }
114
- else {
115
- // 冗長な個人情報をmask
116
- return Object.assign(Object.assign({
117
- // whitelistで作成する(2022-07-19~)
118
- project: order.project, typeOf: order.typeOf, seller: order.seller, price: order.price, priceCurrency: order.priceCurrency, confirmationNumber: order.confirmationNumber, orderNumber: order.orderNumber, acceptedOffers: order.acceptedOffers, orderStatus: order.orderStatus, orderDate: order.orderDate,
119
- // mask
120
- customer: Object.assign(Object.assign({}, (0, order_1.createMaskedCustomer)(order, { noProfile: false })), { additionalProperty: (Array.isArray(order.customer.additionalProperty)) ? order.customer.additionalProperty : [],
121
- // identifierは必要
122
- // 予約後を隠蔽(2022-12-24~)
123
- identifier: (Array.isArray(order.customer.identifier))
124
- ? order.customer.identifier.filter((p) => {
125
- return !reservedAgentIdentifireNames_1.RESERVED_AGENT_IDENTIFIER_NAMES.includes(p.name);
126
- })
127
- : [] }),
128
- // paymentMethodsに関してもmask(2022-05-30~)
129
- paymentMethods: order.paymentMethods.map((p) => {
130
- return Object.assign(Object.assign({}, p), (typeof p.accountId === 'string' && p.accountId.length > 0)
131
- ? { accountId: ASTERISK_CHARACTER.repeat(p.accountId.length) }
132
- : undefined);
133
- }) }, (typeof order.token === 'string')
134
- ? { token: order.token }
135
- : undefined), (typeof order.id === 'string') ? { id: order.id } : undefined);
136
- }
137
- }
138
- else {
139
- return order;
140
- }
141
- }
142
- function createConfirmReservationActionObject4ChevreByOrder(params) {
143
- const chevreReservationNumbers = (Array.isArray(params.order.acceptedOffers))
144
- ? params.order.acceptedOffers.filter((o) => {
145
- var _a;
146
- return (o.itemOffered.typeOf === factory.reservationType.EventReservation
147
- || o.itemOffered.typeOf === factory.reservationType.BusReservation)
148
- && ((_a = o.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier) === factory.service.webAPI.Identifier.Chevre;
149
- })
150
- .map((o) => {
151
- return o.itemOffered.reservationNumber;
152
- })
153
- : [];
154
- return [...new Set(chevreReservationNumbers)].map((reservationNumber) => {
155
- return {
156
- potentialActions: {
157
- reserve: {
158
- purpose: {
159
- confirmationNumber: params.order.confirmationNumber,
160
- orderNumber: params.order.orderNumber,
161
- typeOf: factory.order.OrderType.Order
162
- }
163
- }
164
- },
165
- transactionNumber: reservationNumber,
166
- typeOf: factory.assetTransactionType.Reserve
167
- };
168
- });
169
- }
170
- exports.createConfirmReservationActionObject4ChevreByOrder = createConfirmReservationActionObject4ChevreByOrder;
171
- function createConfirmReservationActionObject4COAByOrder(params) {
172
- // COA予約のみ
173
- const coaReservationOffers = (Array.isArray(params.order.acceptedOffers))
174
- ? params.order.acceptedOffers.filter((o) => {
175
- var _a;
176
- return o.itemOffered.typeOf === factory.reservationType.EventReservation
177
- && ((_a = o.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier) === factory.service.webAPI.Identifier.COA;
178
- })
179
- : [];
180
- const coaReservationNumbers = [...new Set(coaReservationOffers
181
- .map((o) => {
182
- return o.itemOffered.reservationNumber;
183
- }))];
184
- const customer = params.order.customer;
185
- // 電話番号のフォーマットを日本人にリーダブルに調整(COAではこのフォーマットで扱うので)
186
- const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
187
- const phoneNumber = phoneUtil.parse(customer.telephone, 'JP');
188
- let telNum = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.NATIONAL);
189
- // COAでは数字のみ受け付けるので数字以外を除去
190
- telNum = telNum.replace(/[^\d]/g, '');
191
- const mailAddr = customer.email;
192
- if (mailAddr === undefined) {
193
- throw new factory.errors.Argument('order', 'order.customer.email undefined');
194
- }
195
- return coaReservationNumbers.map((reservationNumber) => {
196
- const coaReservations = coaReservationOffers
197
- .filter((o) => o.itemOffered.reservationNumber === reservationNumber)
198
- .map((o) => {
199
- return o.itemOffered;
200
- });
201
- const coaReservation = coaReservations[0];
202
- const reservationForCOAInfo = coaReservation.reservationFor.coaInfo;
203
- if (reservationForCOAInfo === undefined) {
204
- throw new factory.errors.NotFound('reservationFor.coaInfo');
205
- }
206
- const totalPrice = coaReservation.reservedTicket.coaReserveAmount;
207
- if (totalPrice === undefined) {
208
- throw new factory.errors.NotFound('reservedTicket.coaReserveAmount');
209
- }
210
- const listTicket = coaReservations.map((r) => {
211
- var _a;
212
- if (typeof ((_a = r.reservedTicket.coaTicketInfo) === null || _a === void 0 ? void 0 : _a.ticketCode) !== 'string') {
213
- throw new factory.errors.NotFound('reservedTicket.coaTicketInfo');
214
- }
215
- // 冗長な属性を排除(2023-03-20~)
216
- const { ticketCode, stdPrice, addPrice, spseatAdd1, spseatAdd2, disPrice, salePrice, mvtkAppPrice, ticketCount, spseatKbn, seatNum, addGlasses, kbnEisyahousiki, mvtkNum, mvtkKbnDenshiken, mvtkKbnMaeuriken, mvtkKbnKensyu, mvtkSalesPrice, kbnMgtk } = r.reservedTicket.coaTicketInfo;
217
- return {
218
- ticketCode, stdPrice, addPrice, spseatAdd1, spseatAdd2,
219
- disPrice, salePrice, mvtkAppPrice, ticketCount, spseatKbn,
220
- seatNum, addGlasses, kbnEisyahousiki, mvtkNum, mvtkKbnDenshiken,
221
- mvtkKbnMaeuriken, mvtkKbnKensyu, mvtkSalesPrice, kbnMgtk
222
- };
223
- });
224
- return {
225
- theaterCode: reservationForCOAInfo.theaterCode,
226
- dateJouei: reservationForCOAInfo.dateJouei,
227
- titleCode: reservationForCOAInfo.titleCode,
228
- titleBranchNum: reservationForCOAInfo.titleBranchNum,
229
- timeBegin: reservationForCOAInfo.timeBegin,
230
- tmpReserveNum: reservationNumber,
231
- // tslint:disable-next-line:no-irregular-whitespace
232
- reserveName: (0, util_1.format)('%s %s', customer.familyName, customer.givenName),
233
- // tslint:disable-next-line:no-irregular-whitespace
234
- reserveNameJkana: (0, util_1.format)('%s %s', customer.familyName, customer.givenName),
235
- telNum: telNum,
236
- mailAddr: mailAddr,
237
- reserveAmount: totalPrice,
238
- listTicket,
239
- transactionNumber: reservationNumber,
240
- typeOf: 'COAReserveTransaction'
241
- };
242
- });
243
- }
244
- exports.createConfirmReservationActionObject4COAByOrder = createConfirmReservationActionObject4COAByOrder;
245
- function createConfirmRegisterServiceActionObjectByOrder(params) {
246
- // いったん保留
247
- const chevreTransactionNumbers = [];
248
- // const chevreReservationNumbers: string[] = (Array.isArray(params.order.acceptedOffers))
249
- // ? params.order.acceptedOffers.filter((o) => {
250
- // return o.itemOffered.typeOf === factory.permit.PermitType.Permit;
251
- // })
252
- // .map((o) => {
253
- // return (<factory.order.IPermit>o.itemOffered).identifier;
254
- // })
255
- // : [];
256
- return [...new Set(chevreTransactionNumbers)].map((transactionNumber) => {
257
- return {
258
- endDate: params.order.orderDate,
259
- transactionNumber,
260
- typeOf: factory.assetTransactionType.RegisterService
261
- };
262
- });
263
- }
264
- exports.createConfirmRegisterServiceActionObjectByOrder = createConfirmRegisterServiceActionObjectByOrder;
265
- // export function createOnPlaceOrderTasksByTransaction(params: {
266
- // object: factory.order.IOrder | IExternalOrder;
267
- // potentialActions?: factory.action.trade.order.IPotentialActions;
268
- // }): factory.task.IAttributes<factory.taskName>[] {
269
- // const potentialActions = params.potentialActions;
270
- // const now = new Date();
271
- // // potentialActionsのためのタスクを生成
272
- // const taskAttributes: factory.task.IAttributes<factory.taskName>[] = [];
273
- // // tslint:disable-next-line:no-single-line-block-comment
274
- // /* istanbul ignore else */
275
- // if (potentialActions !== undefined) {
276
- // // ポイント付与
277
- // // tslint:disable-next-line:no-single-line-block-comment
278
- // /* istanbul ignore else */
279
- // if (Array.isArray(potentialActions.givePointAward)) {
280
- // taskAttributes.push(...potentialActions.givePointAward.map(
281
- // (a): factory.task.IAttributes<factory.taskName.GivePointAward> => {
282
- // return {
283
- // project: a.project,
284
- // name: factory.taskName.GivePointAward,
285
- // status: factory.taskStatus.Ready,
286
- // runsAt: now, // なるはやで実行
287
- // remainingNumberOfTries: 10,
288
- // numberOfTried: 0,
289
- // executionResults: [],
290
- // data: a
291
- // };
292
- // }));
293
- // }
294
- // }
295
- // return taskAttributes;
296
- // }
297
- /**
298
- * 注文配送後のアクション
299
- */
300
- function createOnOrderSentTasksByTransaction(params) {
301
- const potentialActions = params.potentialActions;
302
- const now = new Date();
303
- const taskAttributes = [];
304
- // tslint:disable-next-line:no-single-line-block-comment
305
- /* istanbul ignore else */
306
- if (potentialActions !== undefined) {
307
- if (Array.isArray(potentialActions.registerService)) {
308
- taskAttributes.push(...potentialActions.registerService.map((a) => {
309
- return {
310
- project: a.project,
311
- name: factory.taskName.ConfirmRegisterService,
312
- status: factory.taskStatus.Ready,
313
- runsAt: now,
314
- remainingNumberOfTries: 10,
315
- numberOfTried: 0,
316
- executionResults: [],
317
- data: a
318
- };
319
- }));
320
- }
321
- // 通貨転送
322
- // tslint:disable-next-line:no-single-line-block-comment
323
- /* istanbul ignore else */
324
- if (Array.isArray(potentialActions.moneyTransfer)) {
325
- taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
326
- return {
327
- project: a.project,
328
- name: factory.taskName.ConfirmMoneyTransfer,
329
- status: factory.taskStatus.Ready,
330
- runsAt: now,
331
- remainingNumberOfTries: 10,
332
- numberOfTried: 0,
333
- executionResults: [],
334
- data: a
335
- };
336
- }));
337
- }
338
- // tslint:disable-next-line:no-single-line-block-comment
339
- /* istanbul ignore else */
340
- if (Array.isArray(potentialActions.sendEmailMessage)) {
341
- potentialActions.sendEmailMessage.forEach((s) => {
342
- const sendEmailMessageTask = {
343
- project: s.project,
344
- name: factory.taskName.SendEmailMessage,
345
- status: factory.taskStatus.Ready,
346
- runsAt: now,
347
- remainingNumberOfTries: 3,
348
- numberOfTried: 0,
349
- executionResults: [],
350
- data: {
351
- actionAttributes: s
352
- }
353
- };
354
- taskAttributes.push(sendEmailMessageTask);
355
- });
356
- }
357
- }
358
- return taskAttributes;
359
- }
360
- exports.createOnOrderSentTasksByTransaction = createOnOrderSentTasksByTransaction;
361
- /**
362
- * 注文返品後のアクション
363
- */
364
- function createOnOrderReturnedTasksByTransaction(params) {
365
- const now = new Date();
366
- const taskAttributes = [];
367
- const potentialActions = params.potentialActions;
368
- // 入金返却タスク
369
- const returnMoneyTransferAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.returnMoneyTransfer;
370
- if (Array.isArray(returnMoneyTransferAttributes)) {
371
- taskAttributes.push(...returnMoneyTransferAttributes.map((a) => {
372
- return {
373
- project: a.project,
374
- name: factory.taskName.ReturnMoneyTransfer,
375
- status: factory.taskStatus.Ready,
376
- runsAt: now,
377
- remainingNumberOfTries: 10,
378
- numberOfTried: 0,
379
- executionResults: [],
380
- data: a
381
- };
382
- }));
383
- }
384
- // ポイント特典返却タスク
385
- const returnPointAwardAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.returnPointAward;
386
- if (Array.isArray(returnPointAwardAttributes)) {
387
- taskAttributes.push(...returnPointAwardAttributes.map((a) => {
388
- return {
389
- project: a.project,
390
- name: factory.taskName.ReturnPointAward,
391
- status: factory.taskStatus.Ready,
392
- runsAt: now,
393
- remainingNumberOfTries: 10,
394
- numberOfTried: 0,
395
- executionResults: [],
396
- data: a
397
- };
398
- }));
399
- }
400
- const sendEmailMessageAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.sendEmailMessage;
401
- if (Array.isArray(sendEmailMessageAttributes)) {
402
- sendEmailMessageAttributes.forEach((s) => {
403
- const sendEmailMessageTask = {
404
- project: s.project,
405
- name: factory.taskName.SendEmailMessage,
406
- status: factory.taskStatus.Ready,
407
- runsAt: now,
408
- remainingNumberOfTries: 3,
409
- numberOfTried: 0,
410
- executionResults: [],
411
- data: {
412
- actionAttributes: s
413
- }
414
- };
415
- taskAttributes.push(sendEmailMessageTask);
416
- });
417
- }
418
- return taskAttributes;
419
- }
420
- exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
421
- /**
422
- * 注文中止時のアクション
423
- */
424
- function createOnOrderCancelledTasksByTransaction(params) {
425
- var _a;
426
- const now = new Date();
427
- const taskAttributes = [];
428
- if (typeof ((_a = params.transaction) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
429
- const voidPaymentTaskAttributes = {
430
- project: params.transaction.project,
431
- name: factory.taskName.VoidPayTransaction,
432
- status: factory.taskStatus.Ready,
433
- runsAt: now,
434
- remainingNumberOfTries: 10,
435
- numberOfTried: 0,
436
- executionResults: [],
437
- data: {
438
- project: params.transaction.project,
439
- purpose: {
440
- typeOf: params.transaction.typeOf,
441
- id: params.transaction.id,
442
- result: { order: { orderStatus: factory.orderStatus.OrderCancelled } }
443
- }
444
- }
445
- };
446
- const voidReserveTaskAttributes = {
447
- project: params.transaction.project,
448
- name: factory.taskName.VoidReserveTransaction,
449
- status: factory.taskStatus.Ready,
450
- runsAt: now,
451
- remainingNumberOfTries: 10,
452
- numberOfTried: 0,
453
- executionResults: [],
454
- data: {
455
- project: params.transaction.project,
456
- purpose: {
457
- typeOf: params.transaction.typeOf,
458
- id: params.transaction.id,
459
- result: { order: { orderStatus: factory.orderStatus.OrderCancelled } }
460
- }
461
- }
462
- };
463
- taskAttributes.push(voidPaymentTaskAttributes, voidReserveTaskAttributes);
464
- }
465
- return taskAttributes;
466
- }
467
- exports.createOnOrderCancelledTasksByTransaction = createOnOrderCancelledTasksByTransaction;
@@ -1,26 +0,0 @@
1
- /**
2
- * findPaymentCardPermit
3
- */
4
- import type { MongoRepository as OwnershipInfoRepo } from '../../../repo/ownershipInfo';
5
- import type { MongoRepository as ProductRepo } from '../../../repo/product';
6
- import * as factory from '../../../factory';
7
- /**
8
- * 所有ペイメントカードを検索
9
- * 指定した通貨の所有ペイメントカードを検索する
10
- */
11
- export declare function findPaymentCardPermit(params: {
12
- customer: {
13
- id: string;
14
- };
15
- project: {
16
- id: string;
17
- };
18
- now: Date;
19
- /**
20
- * 通貨区分
21
- */
22
- accountType: string;
23
- }): (repos: {
24
- ownershipInfo: OwnershipInfoRepo;
25
- product: ProductRepo;
26
- }) => Promise<factory.ownershipInfo.IPermitAsGood>;
@@ -1,65 +0,0 @@
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.findPaymentCardPermit = void 0;
13
- const factory = require("../../../factory");
14
- /**
15
- * 所有ペイメントカードを検索
16
- * 指定した通貨の所有ペイメントカードを検索する
17
- */
18
- function findPaymentCardPermit(params) {
19
- return (repos) => __awaiter(this, void 0, void 0, function* () {
20
- const searchProductsResult = yield repos.product.search({
21
- limit: 1,
22
- page: 1,
23
- project: { id: { $eq: params.project.id } },
24
- typeOf: { $eq: factory.product.ProductType.PaymentCard }
25
- }, [], []);
26
- const accountProduct = searchProductsResult
27
- .find((p) => { var _a, _b; return ((_b = (_a = p.serviceOutput) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency) === params.accountType; });
28
- if (accountProduct === undefined) {
29
- throw new factory.errors.NotFound(`${params.accountType} PaymentCard Product`);
30
- }
31
- let accountOwnershipInfos = [];
32
- try {
33
- // 口座所有権を検索
34
- const searchOwnershipInfosResult = yield repos.ownershipInfo.search({
35
- // 最も古い所有ペイメントカードをデフォルトペイメントカードとして扱う使用なので、ソート条件は以下の通り
36
- sort: { ownedFrom: factory.sortType.Ascending },
37
- limit: 1,
38
- page: 1,
39
- // 詳細取得できていないが、必要ない
40
- typeOfGood: {
41
- issuedThrough: {
42
- id: { $eq: String(accountProduct.id) },
43
- typeOf: { $eq: factory.product.ProductType.PaymentCard }
44
- }
45
- },
46
- ownedFrom: params.now,
47
- ownedThrough: params.now,
48
- ownedBy: { id: params.customer.id }
49
- });
50
- accountOwnershipInfos = searchOwnershipInfosResult;
51
- }
52
- catch (error) {
53
- throw error;
54
- }
55
- // Openedしか存在しなくなったので、この処理は不要です
56
- // accountOwnershipInfos = accountOwnershipInfos.filter(
57
- // (o) => o.typeOfGood.paymentAccount?.status === factory.accountStatusType.Opened
58
- // );
59
- if (accountOwnershipInfos.length === 0) {
60
- throw new factory.errors.NotFound('OwnershipInfos of PaymentCard');
61
- }
62
- return accountOwnershipInfos[0].typeOfGood;
63
- });
64
- }
65
- exports.findPaymentCardPermit = findPaymentCardPermit;