@chevre/domain 21.7.0-alpha.1 → 21.7.0-alpha.11
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.
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +83 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +19 -11
- package/lib/chevre/emailMessageBuilder.d.ts +1 -1
- package/lib/chevre/repo/action.d.ts +4 -0
- package/lib/chevre/repo/action.js +6 -0
- package/lib/chevre/repo/event.d.ts +12 -0
- package/lib/chevre/repo/event.js +11 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/offer.js +5 -6
- package/lib/chevre/repo/product.d.ts +1 -1
- package/lib/chevre/repo/product.js +1 -0
- package/lib/chevre/repo/transaction.d.ts +4 -1
- package/lib/chevre/repo/transaction.js +7 -1
- package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/factory.js +49 -27
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +39 -18
- package/lib/chevre/service/assetTransaction/refund/factory.js +2 -2
- package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
- package/lib/chevre/service/order/deleteOrder.js +42 -0
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged.js +118 -1
- package/lib/chevre/service/order/placeOrder.d.ts +1 -2
- package/lib/chevre/service/order/placeOrder.js +15 -74
- package/lib/chevre/service/payment/any/factory.js +18 -7
- package/lib/chevre/service/payment/creditCard.js +3 -1
- package/lib/chevre/service/payment/paymentCard.js +6 -2
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +1 -5
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +0 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +11 -9
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +6 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +6 -20
- package/lib/chevre/service/transaction/placeOrderInProgress.js +0 -3
- package/lib/chevre/service/transaction/returnOrder.js +0 -1
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +3 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateReservationProvider.ts +0 -119
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.deleteOrder = void 0;
|
|
13
13
|
const factory_1 = require("../delivery/factory");
|
|
14
14
|
const factory = require("../../factory");
|
|
15
|
+
const settings_1 = require("../../settings");
|
|
15
16
|
/**
|
|
16
17
|
* 注文に関わるリソースを削除する
|
|
17
18
|
* 冪等性を確保すること
|
|
@@ -38,6 +39,10 @@ function deleteOrder(params) {
|
|
|
38
39
|
}
|
|
39
40
|
// 経理レポート削除
|
|
40
41
|
yield repos.accountingReport.deleteByOrderNumber({ mainEntity: { orderNumber: order.orderNumber } });
|
|
42
|
+
// 終了済の関連イベントを削除(2023-08-16~)
|
|
43
|
+
if (settings_1.USE_DELETE_EVENT_BY_ORDER) {
|
|
44
|
+
yield deleteEventsByOrder(order)(repos);
|
|
45
|
+
}
|
|
41
46
|
// 注文削除
|
|
42
47
|
yield repos.order.deleteByOrderNumber({ orderNumber: order.orderNumber });
|
|
43
48
|
});
|
|
@@ -73,3 +78,40 @@ function deleteOwnershipInfosByOrder(order) {
|
|
|
73
78
|
}
|
|
74
79
|
});
|
|
75
80
|
}
|
|
81
|
+
function deleteEventsByOrder(order) {
|
|
82
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const now = new Date();
|
|
84
|
+
const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
|
|
85
|
+
const reservationForIds = acceptedOffers.filter((o) => {
|
|
86
|
+
return (o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
87
|
+
|| o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
88
|
+
&& typeof o.itemOffered.reservationFor.id === 'string';
|
|
89
|
+
})
|
|
90
|
+
.map((o) => {
|
|
91
|
+
return String(o.itemOffered.reservationFor.id);
|
|
92
|
+
});
|
|
93
|
+
if (reservationForIds.length > 0) {
|
|
94
|
+
for (const reservationForId of reservationForIds) {
|
|
95
|
+
// 関連注文が存在しなければ削除
|
|
96
|
+
const relatedOrders = yield repos.order.search({
|
|
97
|
+
limit: 1,
|
|
98
|
+
page: 1,
|
|
99
|
+
project: { id: { $eq: order.project.id } },
|
|
100
|
+
acceptedOffers: {
|
|
101
|
+
itemOffered: {
|
|
102
|
+
reservationFor: { ids: [reservationForId] }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, { _id: 1 });
|
|
106
|
+
if (relatedOrders.length === 0) {
|
|
107
|
+
yield repos.event.deleteManyEndedByIds({
|
|
108
|
+
typeOf: { $in: [factory.eventType.Event, factory.eventType.ScreeningEvent] },
|
|
109
|
+
project: { id: order.project.id },
|
|
110
|
+
ids: [reservationForId],
|
|
111
|
+
endDate: { $lte: now }
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
@@ -11,4 +11,5 @@ export declare function onOrderStatusChanged(params: {
|
|
|
11
11
|
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
12
12
|
task: TaskRepo;
|
|
13
13
|
}) => Promise<void>;
|
|
14
|
+
export type IExternalOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'seller' | 'customer' | 'confirmationNumber' | 'orderNumber' | 'price' | 'priceCurrency' | 'orderDate' | 'name' | 'orderStatus' | 'orderedItem' | 'paymentMethods'>;
|
|
14
15
|
export {};
|
|
@@ -23,6 +23,7 @@ const USE_CONFIRM_REGISTER_SERVICE_TRANSACTION = process.env.USE_CONFIRM_REGISTE
|
|
|
23
23
|
const TOKEN_EXPIRES_IN = 604800;
|
|
24
24
|
function onOrderStatusChanged(params) {
|
|
25
25
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b, _c;
|
|
26
27
|
let tasks = [];
|
|
27
28
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
28
29
|
const simpleOrder = {
|
|
@@ -76,7 +77,13 @@ function onOrderStatusChanged(params) {
|
|
|
76
77
|
...(0, factory_1.createInformTasks)(orderWithToken),
|
|
77
78
|
...yield createConfirmPayTransactionTasks(params.order, simpleOrder)(repos),
|
|
78
79
|
...yield createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
|
|
79
|
-
...yield createConfirmRegisterServiceTransactionTasks(params.order, simpleOrder)(repos)
|
|
80
|
+
...yield createConfirmRegisterServiceTransactionTasks(params.order, simpleOrder)(repos),
|
|
81
|
+
// 取引のpotentialActionsを適用(2023-08-17~)
|
|
82
|
+
...createOnPlaceOrderTasksByTransaction({
|
|
83
|
+
object: params.order,
|
|
84
|
+
// potentialActions: params.potentialActions
|
|
85
|
+
potentialActions: (_c = (_b = (_a = params.placeOrderTransaction) === null || _a === void 0 ? void 0 : _a.potentialActions) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.potentialActions
|
|
86
|
+
})
|
|
80
87
|
];
|
|
81
88
|
break;
|
|
82
89
|
case factory.orderStatus.OrderReturned:
|
|
@@ -363,3 +370,113 @@ function createReturnPayTransactionTasks(order, __, returnOrderTransaction) {
|
|
|
363
370
|
return tasks;
|
|
364
371
|
});
|
|
365
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* 注文作成後のアクション
|
|
375
|
+
*/
|
|
376
|
+
// export function onPlaceOrder(params: {
|
|
377
|
+
// object: factory.order.IOrder | IExternalOrder;
|
|
378
|
+
// potentialActions?: factory.action.trade.order.IPotentialActions;
|
|
379
|
+
// }) {
|
|
380
|
+
// return async (repos: {
|
|
381
|
+
// task: TaskRepo;
|
|
382
|
+
// }) => {
|
|
383
|
+
// const potentialActions = params.potentialActions;
|
|
384
|
+
// const now = new Date();
|
|
385
|
+
// // potentialActionsのためのタスクを生成
|
|
386
|
+
// const taskAttributes: factory.task.IAttributes<factory.taskName>[] = [];
|
|
387
|
+
// // tslint:disable-next-line:no-single-line-block-comment
|
|
388
|
+
// /* istanbul ignore else */
|
|
389
|
+
// if (potentialActions !== undefined) {
|
|
390
|
+
// // tslint:disable-next-line:no-single-line-block-comment
|
|
391
|
+
// /* istanbul ignore else */
|
|
392
|
+
// if (potentialActions.sendOrder !== undefined) {
|
|
393
|
+
// const sendOrderTask: factory.task.IAttributes<factory.taskName.SendOrder> = {
|
|
394
|
+
// project: potentialActions.sendOrder.project,
|
|
395
|
+
// name: factory.taskName.SendOrder,
|
|
396
|
+
// status: factory.taskStatus.Ready,
|
|
397
|
+
// runsAt: now, // なるはやで実行
|
|
398
|
+
// remainingNumberOfTries: 10,
|
|
399
|
+
// numberOfTried: 0,
|
|
400
|
+
// executionResults: [],
|
|
401
|
+
// // data: potentialActions.sendOrder
|
|
402
|
+
// data: {
|
|
403
|
+
// project: potentialActions.sendOrder.project,
|
|
404
|
+
// object: {
|
|
405
|
+
// ...potentialActions.sendOrder.object,
|
|
406
|
+
// confirmationNumber: params.object.confirmationNumber
|
|
407
|
+
// },
|
|
408
|
+
// ...(potentialActions.sendOrder.potentialActions !== undefined)
|
|
409
|
+
// ? { potentialActions: potentialActions.sendOrder.potentialActions }
|
|
410
|
+
// : undefined
|
|
411
|
+
// }
|
|
412
|
+
// };
|
|
413
|
+
// taskAttributes.push(sendOrderTask);
|
|
414
|
+
// }
|
|
415
|
+
// // ポイント付与
|
|
416
|
+
// // tslint:disable-next-line:no-single-line-block-comment
|
|
417
|
+
// /* istanbul ignore else */
|
|
418
|
+
// if (Array.isArray(potentialActions.givePointAward)) {
|
|
419
|
+
// taskAttributes.push(...potentialActions.givePointAward.map(
|
|
420
|
+
// (a): factory.task.IAttributes<factory.taskName.GivePointAward> => {
|
|
421
|
+
// return {
|
|
422
|
+
// project: a.project,
|
|
423
|
+
// name: factory.taskName.GivePointAward,
|
|
424
|
+
// status: factory.taskStatus.Ready,
|
|
425
|
+
// runsAt: now, // なるはやで実行
|
|
426
|
+
// remainingNumberOfTries: 10,
|
|
427
|
+
// numberOfTried: 0,
|
|
428
|
+
// executionResults: [],
|
|
429
|
+
// data: a
|
|
430
|
+
// };
|
|
431
|
+
// }));
|
|
432
|
+
// }
|
|
433
|
+
// }
|
|
434
|
+
// // タスク保管
|
|
435
|
+
// await repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
436
|
+
// };
|
|
437
|
+
// }
|
|
438
|
+
function createOnPlaceOrderTasksByTransaction(params) {
|
|
439
|
+
const potentialActions = params.potentialActions;
|
|
440
|
+
const now = new Date();
|
|
441
|
+
// potentialActionsのためのタスクを生成
|
|
442
|
+
const taskAttributes = [];
|
|
443
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
444
|
+
/* istanbul ignore else */
|
|
445
|
+
if (potentialActions !== undefined) {
|
|
446
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
447
|
+
/* istanbul ignore else */
|
|
448
|
+
if (potentialActions.sendOrder !== undefined) {
|
|
449
|
+
const sendOrderTask = {
|
|
450
|
+
project: potentialActions.sendOrder.project,
|
|
451
|
+
name: factory.taskName.SendOrder,
|
|
452
|
+
status: factory.taskStatus.Ready,
|
|
453
|
+
runsAt: now,
|
|
454
|
+
remainingNumberOfTries: 10,
|
|
455
|
+
numberOfTried: 0,
|
|
456
|
+
executionResults: [],
|
|
457
|
+
data: Object.assign({ project: potentialActions.sendOrder.project, object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber }) }, (potentialActions.sendOrder.potentialActions !== undefined)
|
|
458
|
+
? { potentialActions: potentialActions.sendOrder.potentialActions }
|
|
459
|
+
: undefined)
|
|
460
|
+
};
|
|
461
|
+
taskAttributes.push(sendOrderTask);
|
|
462
|
+
}
|
|
463
|
+
// ポイント付与
|
|
464
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
465
|
+
/* istanbul ignore else */
|
|
466
|
+
if (Array.isArray(potentialActions.givePointAward)) {
|
|
467
|
+
taskAttributes.push(...potentialActions.givePointAward.map((a) => {
|
|
468
|
+
return {
|
|
469
|
+
project: a.project,
|
|
470
|
+
name: factory.taskName.GivePointAward,
|
|
471
|
+
status: factory.taskStatus.Ready,
|
|
472
|
+
runsAt: now,
|
|
473
|
+
remainingNumberOfTries: 10,
|
|
474
|
+
numberOfTried: 0,
|
|
475
|
+
executionResults: [],
|
|
476
|
+
data: a
|
|
477
|
+
};
|
|
478
|
+
}));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return taskAttributes;
|
|
482
|
+
}
|
|
@@ -4,8 +4,8 @@ import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/act
|
|
|
4
4
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
5
5
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
6
6
|
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
7
|
+
import { IExternalOrder } from './onOrderStatusChanged';
|
|
7
8
|
import * as factory from '../../factory';
|
|
8
|
-
type IExternalOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'seller' | 'customer' | 'confirmationNumber' | 'orderNumber' | 'price' | 'priceCurrency' | 'orderDate' | 'name' | 'orderStatus' | 'orderedItem' | 'paymentMethods'>;
|
|
9
9
|
/**
|
|
10
10
|
* 注文取引なしに注文を作成する
|
|
11
11
|
*/
|
|
@@ -15,7 +15,6 @@ declare function placeOrderWithoutTransaction(params: {
|
|
|
15
15
|
id: string;
|
|
16
16
|
};
|
|
17
17
|
object: IExternalOrder;
|
|
18
|
-
potentialActions?: factory.action.trade.order.IPotentialActions;
|
|
19
18
|
}): (repos: {
|
|
20
19
|
accountingReport: AccountingReportRepo;
|
|
21
20
|
action: ActionRepo;
|
|
@@ -98,12 +98,6 @@ function placeOrderWithoutTransaction(params) {
|
|
|
98
98
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
99
99
|
var _a;
|
|
100
100
|
const order = params.object;
|
|
101
|
-
// 注文番号から取引と注文をfixする
|
|
102
|
-
// const { order, placeOrderTransaction } = await createOrderFromBody({
|
|
103
|
-
// project: { id: params.project.id },
|
|
104
|
-
// confirmationNumber: params.object.confirmationNumber,
|
|
105
|
-
// orderNumber: params.object.orderNumber
|
|
106
|
-
// })({ transaction: repos.transaction });
|
|
107
101
|
// アクションを作成する(2022-04-11~)
|
|
108
102
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
109
103
|
const simpleOrder = {
|
|
@@ -145,21 +139,17 @@ function placeOrderWithoutTransaction(params) {
|
|
|
145
139
|
yield repos.action.complete({ typeOf: orderActionAttributes.typeOf, id: action.id, result: {} });
|
|
146
140
|
// 経理レポートを保管
|
|
147
141
|
yield (0, createAccountingReportIfNotExist_1.createAccountingReportIfNotExist)(order)({ accountingReport: repos.accountingReport });
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
// 潜在アクション
|
|
153
|
-
yield onPlaceOrder({
|
|
154
|
-
object: order,
|
|
155
|
-
potentialActions: params.potentialActions
|
|
156
|
-
})(repos);
|
|
142
|
+
// await onOrderStatusChanged({ order: <factory.order.IOrder>order })({
|
|
143
|
+
// registerActionInProgress: repos.registerActionInProgress,
|
|
144
|
+
// task: repos.task
|
|
145
|
+
// });
|
|
157
146
|
});
|
|
158
147
|
}
|
|
159
148
|
exports.placeOrderWithoutTransaction = placeOrderWithoutTransaction;
|
|
160
149
|
/**
|
|
161
150
|
* 注文を作成する
|
|
162
151
|
*/
|
|
152
|
+
// tslint:disable-next-line:max-func-body-length
|
|
163
153
|
function placeOrder(params) {
|
|
164
154
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
165
155
|
var _a;
|
|
@@ -226,71 +216,22 @@ function placeOrder(params) {
|
|
|
226
216
|
}
|
|
227
217
|
yield repos.action.complete({ typeOf: orderActionAttributes.typeOf, id: action.id, result: {} });
|
|
228
218
|
}
|
|
229
|
-
if (
|
|
219
|
+
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
220
|
+
throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
221
|
+
}
|
|
222
|
+
if (params.useOnOrderStatusChanged) {
|
|
230
223
|
// 経理レポートを保管
|
|
231
224
|
yield (0, createAccountingReportIfNotExist_1.createAccountingReportIfNotExist)(order)({ accountingReport: repos.accountingReport });
|
|
232
|
-
yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({ order })({
|
|
225
|
+
yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({ order, placeOrderTransaction })({
|
|
233
226
|
registerActionInProgress: repos.registerActionInProgress,
|
|
234
227
|
task: repos.task
|
|
235
228
|
});
|
|
236
229
|
}
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
})(repos);
|
|
230
|
+
// onOrderStatusChangedへ移行(2023-08-17~)
|
|
231
|
+
// await onPlaceOrder({
|
|
232
|
+
// object: order,
|
|
233
|
+
// potentialActions: params.potentialActions
|
|
234
|
+
// })(repos);
|
|
242
235
|
});
|
|
243
236
|
}
|
|
244
237
|
exports.placeOrder = placeOrder;
|
|
245
|
-
/**
|
|
246
|
-
* 注文作成後のアクション
|
|
247
|
-
*/
|
|
248
|
-
function onPlaceOrder(params) {
|
|
249
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
const potentialActions = params.potentialActions;
|
|
251
|
-
const now = new Date();
|
|
252
|
-
// potentialActionsのためのタスクを生成
|
|
253
|
-
const taskAttributes = [];
|
|
254
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
255
|
-
/* istanbul ignore else */
|
|
256
|
-
if (potentialActions !== undefined) {
|
|
257
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
258
|
-
/* istanbul ignore else */
|
|
259
|
-
if (potentialActions.sendOrder !== undefined) {
|
|
260
|
-
const sendOrderTask = {
|
|
261
|
-
project: potentialActions.sendOrder.project,
|
|
262
|
-
name: factory.taskName.SendOrder,
|
|
263
|
-
status: factory.taskStatus.Ready,
|
|
264
|
-
runsAt: now,
|
|
265
|
-
remainingNumberOfTries: 10,
|
|
266
|
-
numberOfTried: 0,
|
|
267
|
-
executionResults: [],
|
|
268
|
-
// data: potentialActions.sendOrder
|
|
269
|
-
data: Object.assign({ project: potentialActions.sendOrder.project, object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber }) }, (potentialActions.sendOrder.potentialActions !== undefined)
|
|
270
|
-
? { potentialActions: potentialActions.sendOrder.potentialActions }
|
|
271
|
-
: undefined)
|
|
272
|
-
};
|
|
273
|
-
taskAttributes.push(sendOrderTask);
|
|
274
|
-
}
|
|
275
|
-
// ポイント付与
|
|
276
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
277
|
-
/* istanbul ignore else */
|
|
278
|
-
if (Array.isArray(potentialActions.givePointAward)) {
|
|
279
|
-
taskAttributes.push(...potentialActions.givePointAward.map((a) => {
|
|
280
|
-
return {
|
|
281
|
-
project: a.project,
|
|
282
|
-
name: factory.taskName.GivePointAward,
|
|
283
|
-
status: factory.taskStatus.Ready,
|
|
284
|
-
runsAt: now,
|
|
285
|
-
remainingNumberOfTries: 10,
|
|
286
|
-
numberOfTried: 0,
|
|
287
|
-
executionResults: [],
|
|
288
|
-
data: a
|
|
289
|
-
};
|
|
290
|
-
}));
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
// タスク保管
|
|
294
|
-
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
295
|
-
});
|
|
296
|
-
}
|
|
@@ -80,28 +80,39 @@ function createMovieTicket(params) {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
function createAuthorizeResult(params) {
|
|
83
|
-
var _a, _b, _c, _d, _e, _f;
|
|
83
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
84
84
|
const payTransactionObject = params.payTransaction.object;
|
|
85
85
|
const totalPaymentDue = (_a = payTransactionObject.paymentMethod) === null || _a === void 0 ? void 0 : _a.totalPaymentDue;
|
|
86
86
|
if (typeof (totalPaymentDue === null || totalPaymentDue === void 0 ? void 0 : totalPaymentDue.typeOf) !== 'string') {
|
|
87
87
|
throw new factory.errors.ServiceUnavailable('payTransaction.object.paymentMethod.totalPaymentDue undefined');
|
|
88
88
|
}
|
|
89
|
-
const issuedThrough =
|
|
90
|
-
|
|
89
|
+
const issuedThrough = {
|
|
90
|
+
typeOf: payTransactionObject.typeOf,
|
|
91
|
+
id: (typeof payTransactionObject.id === 'string') ? payTransactionObject.id : ''
|
|
92
|
+
};
|
|
93
|
+
// 決済取引から決済カード通貨区分を取り出す
|
|
94
|
+
const paymentMethodAmountCurrencyByPayTransaction = (typeof ((_b = payTransactionObject.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount) !== 'number')
|
|
95
|
+
? (_d = (_c = payTransactionObject.paymentMethod) === null || _c === void 0 ? void 0 : _c.amount) === null || _d === void 0 ? void 0 : _d.currency
|
|
96
|
+
: undefined;
|
|
97
|
+
const paymentMethodAsObject = Object.assign({ typeOf: params.object.paymentMethod }, (payTransactionObject.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
|
|
98
|
+
&& typeof paymentMethodAmountCurrencyByPayTransaction === 'string')
|
|
99
|
+
? { amount: { currency: paymentMethodAmountCurrencyByPayTransaction } }
|
|
91
100
|
: undefined);
|
|
92
101
|
return {
|
|
93
|
-
accountId: (typeof ((
|
|
102
|
+
accountId: (typeof ((_e = payTransactionObject.paymentMethod) === null || _e === void 0 ? void 0 : _e.accountId) === 'string')
|
|
94
103
|
? payTransactionObject.paymentMethod.accountId
|
|
95
104
|
: '',
|
|
96
105
|
// 廃止(2023-08-07~)
|
|
97
106
|
// amount: params.object.amount,
|
|
98
107
|
issuedThrough,
|
|
99
|
-
|
|
108
|
+
// 完全廃止(paymentMethodAsObjectへ完全移行)(2023-08-16~)
|
|
109
|
+
// paymentMethod: params.object.paymentMethod,
|
|
110
|
+
paymentMethodAsObject,
|
|
100
111
|
paymentStatus: factory.paymentStatusType.PaymentDue,
|
|
101
|
-
paymentMethodId: (typeof ((
|
|
112
|
+
paymentMethodId: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.paymentMethodId) === 'string')
|
|
102
113
|
? payTransactionObject.paymentMethod.paymentMethodId
|
|
103
114
|
: '',
|
|
104
|
-
name: (typeof ((
|
|
115
|
+
name: (typeof ((_g = payTransactionObject.paymentMethod) === null || _g === void 0 ? void 0 : _g.name) === 'string')
|
|
105
116
|
? payTransactionObject.paymentMethod.name
|
|
106
117
|
: params.object.paymentMethod,
|
|
107
118
|
totalPaymentDue: totalPaymentDue,
|
|
@@ -114,7 +114,9 @@ function processAuthorizeCreditCard(params) {
|
|
|
114
114
|
shopPass: params.shopPass,
|
|
115
115
|
orderId: params.orderId,
|
|
116
116
|
jobCd: GMO.utils.util.JobCd.Auth,
|
|
117
|
-
amount: params.object.amount
|
|
117
|
+
amount: (typeof params.object.amount === 'number')
|
|
118
|
+
? params.object.amount
|
|
119
|
+
: params.object.amount.value,
|
|
118
120
|
siteId: (_a = params.availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId,
|
|
119
121
|
sitePass: (_b = params.availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass
|
|
120
122
|
};
|
|
@@ -127,7 +127,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
127
127
|
}
|
|
128
128
|
function processAccountTransaction(params) {
|
|
129
129
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
var _a, _b, _c, _d, _e, _f;
|
|
130
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
131
131
|
let pendingTransaction;
|
|
132
132
|
const defaultName = `${factory.assetTransactionType.Pay} Transaction ${params.transactionNumber}`;
|
|
133
133
|
const agent = Object.assign(Object.assign({}, params.agent), { name: (typeof params.agent.name === 'string') ? params.agent.name : defaultName });
|
|
@@ -165,7 +165,11 @@ function processAccountTransaction(params) {
|
|
|
165
165
|
expires: params.expires,
|
|
166
166
|
recipient: recipient,
|
|
167
167
|
object: {
|
|
168
|
-
amount: {
|
|
168
|
+
amount: {
|
|
169
|
+
value: (typeof ((_f = params.paymentMethod) === null || _f === void 0 ? void 0 : _f.amount) === 'number')
|
|
170
|
+
? (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.amount
|
|
171
|
+
: (_h = params.paymentMethod) === null || _h === void 0 ? void 0 : _h.amount.value
|
|
172
|
+
},
|
|
169
173
|
description: description,
|
|
170
174
|
fromLocation: {
|
|
171
175
|
accountNumber: accountNumber
|
|
@@ -13,6 +13,7 @@ exports.call = void 0;
|
|
|
13
13
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
+
const event_1 = require("../../repo/event");
|
|
16
17
|
const order_1 = require("../../repo/order");
|
|
17
18
|
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
18
19
|
const reservation_1 = require("../../repo/reservation");
|
|
@@ -28,6 +29,7 @@ function call(data) {
|
|
|
28
29
|
accountingReport: new accountingReport_1.MongoRepository(settings.connection),
|
|
29
30
|
action: new action_1.MongoRepository(settings.connection),
|
|
30
31
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
32
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
31
33
|
order: new order_1.MongoRepository(settings.connection),
|
|
32
34
|
ownershipInfo: new ownershipInfo_1.MongoRepository(settings.connection),
|
|
33
35
|
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
@@ -2,6 +2,7 @@ import * as factory from '../../factory';
|
|
|
2
2
|
import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
3
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
4
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
5
|
+
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
5
6
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
6
7
|
import { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
7
8
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
@@ -15,6 +16,7 @@ export declare function deleteTransaction(params: factory.task.IData<factory.tas
|
|
|
15
16
|
accountingReport: AccountingReportRepo;
|
|
16
17
|
action: ActionRepo;
|
|
17
18
|
assetTransaction: AssetTransactionRepo;
|
|
19
|
+
event: EventRepo;
|
|
18
20
|
order: OrderRepo;
|
|
19
21
|
ownershipInfo: OwnershipInfoRepo;
|
|
20
22
|
reservation: ReservationRepo;
|
|
@@ -14,12 +14,8 @@ function createStartParams(params, passport, seller, amount, fromLocation, toLoc
|
|
|
14
14
|
id: String(seller.id),
|
|
15
15
|
name: seller.name,
|
|
16
16
|
typeOf: seller.typeOf
|
|
17
|
-
// ↓最適化(2022-05-24~)
|
|
18
|
-
// ...{ project: seller.project }
|
|
19
17
|
},
|
|
20
|
-
object: Object.assign(Object.assign({ amount: amount, fromLocation: fromLocation, toLocation: toLocation,
|
|
21
|
-
// authorizeActions: [],
|
|
22
|
-
pendingTransaction: Object.assign({ transactionNumber }, (typeof ((_a = params.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.identifier) === 'string')
|
|
18
|
+
object: Object.assign(Object.assign({ amount: amount, fromLocation: fromLocation, toLocation: toLocation, pendingTransaction: Object.assign({ transactionNumber }, (typeof ((_a = params.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.identifier) === 'string')
|
|
23
19
|
? { identifier: params.object.pendingTransaction.identifier }
|
|
24
20
|
: undefined) }, (passport !== undefined) ? { passport } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined),
|
|
25
21
|
expires: params.expires
|
|
@@ -117,10 +117,6 @@ function createProductItems(params) {
|
|
|
117
117
|
exports.createProductItems = createProductItems;
|
|
118
118
|
function createMoneyTransferAcceptedOffers(params) {
|
|
119
119
|
// 通貨転送承認アクション
|
|
120
|
-
// const authorizeMoneyTansferActions = (<IAuthorizeMoneyTransferOffer[]>params.transaction.object.authorizeActions)
|
|
121
|
-
// .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
122
|
-
// .filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
123
|
-
// .filter((a) => a.object.itemOffered?.typeOf === factory.actionType.MoneyTransfer);
|
|
124
120
|
const authorizeMoneyTansferActions = params.authorizeActions
|
|
125
121
|
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
126
122
|
.filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
@@ -70,16 +70,18 @@ function createPaymentMethods(params) {
|
|
|
70
70
|
});
|
|
71
71
|
// 決済方法をセット
|
|
72
72
|
authorizePaymentActions.forEach((a) => {
|
|
73
|
+
var _a, _b, _c;
|
|
73
74
|
const result = a.result;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
75
|
+
const paymentMethodAmountCurrencyByAuthorizeAction = (_b = (_a = result.paymentMethodAsObject) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
|
|
76
|
+
const paymentMethodOfInvoice = (typeof paymentMethodAmountCurrencyByAuthorizeAction === 'string') ?
|
|
77
|
+
{ amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } }
|
|
78
|
+
: undefined;
|
|
79
|
+
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
80
|
+
const paymentMethodType = (_c = result.paymentMethodAsObject) === null || _c === void 0 ? void 0 : _c.typeOf;
|
|
81
|
+
if (typeof paymentMethodType !== 'string') {
|
|
82
|
+
throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
|
|
83
|
+
}
|
|
84
|
+
paymentMethods.push(Object.assign({ accountId: result.accountId, additionalProperty: (Array.isArray(result.additionalProperty)) ? result.additionalProperty : [], issuedThrough: result.issuedThrough, name: result.name, paymentMethodId: result.paymentMethodId, totalPaymentDue: result.totalPaymentDue, typeOf: paymentMethodType }, (paymentMethodOfInvoice !== undefined) ? { paymentMethod: paymentMethodOfInvoice } : undefined));
|
|
83
85
|
});
|
|
84
86
|
// 決済方法から注文金額の計算
|
|
85
87
|
// price += authorizePaymentActions
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js
CHANGED
|
@@ -11,14 +11,16 @@ const debug = createDebug('cinerino-domain:service:validateMovieTicket');
|
|
|
11
11
|
* 座席予約オファー承認に対してムビチケ承認条件が整っているかどうか検証する
|
|
12
12
|
*/
|
|
13
13
|
function validateMovieTicket(paymentMethodType, transaction, authorizeActions) {
|
|
14
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
15
14
|
const authorizeMovieTicketActions = authorizeActions.filter((a) => {
|
|
16
|
-
var _a, _b, _c;
|
|
15
|
+
var _a, _b, _c, _d;
|
|
17
16
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
18
17
|
&& ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
19
18
|
&& ((_b = a.result) === null || _b === void 0 ? void 0 : _b.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
20
|
+
&& ((_d = (_c = a.result) === null || _c === void 0 ? void 0 : _c.paymentMethodAsObject) === null || _d === void 0 ? void 0 : _d.typeOf) === paymentMethodType;
|
|
21
|
+
}
|
|
22
|
+
// && a.result?.paymentMethod === paymentMethodType
|
|
23
|
+
);
|
|
22
24
|
const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
23
25
|
&& a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
24
26
|
// 予約によって必要とされるMovieTicket
|
|
@@ -38,10 +38,7 @@ function validateTransaction(transaction, authorizeActions) {
|
|
|
38
38
|
validatePaymentUrl(transaction, authorizeActions);
|
|
39
39
|
}
|
|
40
40
|
exports.validateTransaction = validateTransaction;
|
|
41
|
-
function findMovieTicketPaymentMethodTypesFromTransaction(
|
|
42
|
-
// transaction: factory.transaction.placeOrder.ITransaction,
|
|
43
|
-
authorizeActions) {
|
|
44
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
41
|
+
function findMovieTicketPaymentMethodTypesFromTransaction(authorizeActions) {
|
|
45
42
|
const authorizeMovieTicketPaymentActions = authorizeActions.filter((a) => {
|
|
46
43
|
var _a, _b;
|
|
47
44
|
return a.actionStatus === factory.actionStatusType.CompletedActionStatus
|
|
@@ -55,9 +52,6 @@ authorizeActions) {
|
|
|
55
52
|
seatReservationAuthorizeActions.forEach((action) => {
|
|
56
53
|
var _a;
|
|
57
54
|
// a.objectではなくa.resultを使用する(2022-06-04~)
|
|
58
|
-
// const acceptedOffer =
|
|
59
|
-
// tslint:disable-next-line:max-line-length
|
|
60
|
-
// (<factory.action.authorize.offer.seatReservation.IObject<factory.service.webAPI.Identifier.Chevre>>action.object).acceptedOffer;
|
|
61
55
|
const acceptedOffers = (_a = action.result) === null || _a === void 0 ? void 0 : _a.acceptedOffers;
|
|
62
56
|
acceptedOffers === null || acceptedOffers === void 0 ? void 0 : acceptedOffers.forEach((offer) => {
|
|
63
57
|
var _a;
|
|
@@ -72,14 +66,15 @@ authorizeActions) {
|
|
|
72
66
|
});
|
|
73
67
|
});
|
|
74
68
|
const paymentMethodTypes = [
|
|
75
|
-
|
|
69
|
+
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
70
|
+
...authorizeMovieTicketPaymentActions.map((a) => { var _a, _b; return String((_b = (_a = a.result) === null || _a === void 0 ? void 0 : _a.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.typeOf); }),
|
|
71
|
+
// ...authorizeMovieTicketPaymentActions.map((a) => String(a.result?.paymentMethod)),
|
|
76
72
|
...requiredMovieTicketPaymentMethodTypes
|
|
77
73
|
];
|
|
78
74
|
return [...new Set(paymentMethodTypes)];
|
|
79
75
|
}
|
|
80
76
|
function validateProfile(transaction) {
|
|
81
77
|
// object.customerで検証(2022-05-26~)
|
|
82
|
-
// const profile = transaction.agent;
|
|
83
78
|
const profile = transaction.object.customer;
|
|
84
79
|
if (typeof (profile === null || profile === void 0 ? void 0 : profile.email) !== 'string' || (profile === null || profile === void 0 ? void 0 : profile.email.length) === 0
|
|
85
80
|
|| typeof (profile === null || profile === void 0 ? void 0 : profile.familyName) !== 'string' || (profile === null || profile === void 0 ? void 0 : profile.familyName.length) === 0
|
|
@@ -89,7 +84,6 @@ function validateProfile(transaction) {
|
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
function validatePrice(transaction, authorizeActions) {
|
|
92
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
93
87
|
let priceByAgent = 0;
|
|
94
88
|
let priceBySeller = 0;
|
|
95
89
|
// 決済承認を確認
|
|
@@ -121,7 +115,6 @@ function validatePrice(transaction, authorizeActions) {
|
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
117
|
function validatePaymentUrl(transaction, authorizeActions) {
|
|
124
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
125
118
|
var _a, _b;
|
|
126
119
|
// 決済URLが発行されている場合、検証
|
|
127
120
|
const paymentMethodId = (_a = transaction.object.paymentMethods) === null || _a === void 0 ? void 0 : _a.paymentMethodId;
|
|
@@ -145,10 +138,7 @@ function validatePaymentUrl(transaction, authorizeActions) {
|
|
|
145
138
|
/**
|
|
146
139
|
* JPY以外の通貨について取引を検証する
|
|
147
140
|
*/
|
|
148
|
-
function validateMonetaryAmount(
|
|
149
|
-
// transaction: factory.transaction.placeOrder.ITransaction,
|
|
150
|
-
authorizeActions) {
|
|
151
|
-
// const authorizeActions = transaction.object.authorizeActions;
|
|
141
|
+
function validateMonetaryAmount(authorizeActions) {
|
|
152
142
|
const authorizeMonetaryAmountActions = authorizeActions
|
|
153
143
|
.filter((a) => {
|
|
154
144
|
var _a, _b;
|
|
@@ -216,7 +206,7 @@ function validatePaymentMethods(params) {
|
|
|
216
206
|
const creditCardPaymentMethodCount = params.order.paymentMethods.filter((p) => {
|
|
217
207
|
var _a, _b;
|
|
218
208
|
// カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
|
|
219
|
-
const serviceOutputAmountCurrency = (_b = (_a = p.
|
|
209
|
+
const serviceOutputAmountCurrency = (_b = (_a = p.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
|
|
220
210
|
return p.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
|
|
221
211
|
&& typeof serviceOutputAmountCurrency !== 'string';
|
|
222
212
|
}).length;
|
|
@@ -230,10 +220,6 @@ exports.validatePaymentMethods = validatePaymentMethods;
|
|
|
230
220
|
* イベントオファー適用条件確認
|
|
231
221
|
*/
|
|
232
222
|
function validateEventOffers(params) {
|
|
233
|
-
// const seatReservationAuthorizeActions = <IAuthorizeSeatReservationOffer[]>
|
|
234
|
-
// params.transaction.object.authorizeActions
|
|
235
|
-
// .filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
236
|
-
// .filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|
|
237
223
|
const seatReservationAuthorizeActions = params.authorizeActions
|
|
238
224
|
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
239
225
|
.filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
|